#include "Blocks/LightbulbBlock.h"

namespace PocketSurvival
{
    LightbulbBlock::LightbulbBlock()
    {
        addInheritance((IPaintableBlock*)this);
    }

    int32_t LightbulbBlock::getFace(int32_t value)
    {
        return LightbulbBlock::GetMountingFace(Terrain::ExtractData(value));
    }

    void LightbulbBlock::getCreativeValues(std::vector<int32_t> &blockVec)
    {
        blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, SetColor(0, -1)));
        for(int32_t index = 0; index < 16; ++index)
        {
            blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, SetColor(0, index)));
        }
    }

    void LightbulbBlock::getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues)
    {
    }

    BlockPlacementData LightbulbBlock::getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult)
    {
		BlockPlacementData result;
		result.value = 0;
		result.cellFace = raycastResult.cellFace;
		return result;
    }

    const std::vector<BoundingBox> &LightbulbBlock::getCustomCollisionBoxes(int32_t value)
    {
        int32_t mountingFace = GetMountingFace(Terrain::ExtractData(value));
        if(mountingFace < GET_ARRAY_LEN(BlockConstans::lightbulbCollisionBoxes))
        {
            return BlockConstans::lightbulbCollisionBoxes[mountingFace];
        }
        return BlockConstans::zeroCollisionBoxes;
    }

    int32_t LightbulbBlock::getPaintColor(int32_t value)
    {
        return GetColor(Terrain::ExtractData(value));
    }

    int32_t LightbulbBlock::paint(int32_t value, int32_t color)
    {
        return Terrain::MakeBlockValue(getIndex(), 0, SetColor(Terrain::ExtractData(value), color));
    }

    int32_t LightbulbBlock::getIndex()
    {
        return Index();
    }
    const std::string &LightbulbBlock::getBlockName()
    {
        static std::string blockName = "LightbulbBlock";
        return blockName;
    }
	
} // namespace PocketSurvival
